/**
 * 
 */
package mdb.com.vn.persist;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Repository;

import mdb.com.vn.model.LuckyDrawG1;

/**
 * @author tu.dod
 *
 */
@Repository("luckyDrawG1DAO")
public class LuckyDrawG1DAOImpl extends AbstractHibernateDAOImpl<LuckyDrawG1, Integer> implements LuckyDrawG1DAO,Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected Class<LuckyDrawG1> getDomainClass() {
		// TODO Auto-generated method stub
		return LuckyDrawG1.class;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<LuckyDrawG1> findByRef(String refNo,String status) {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("LuckyDrawG1.findByRef").setString("refNo", refNo).setString("status", status).list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public int countAllLuckyDraw() {
		// TODO Auto-generated method stub
		List<Long> longs = getSession().getNamedQuery("LuckyDrawG1.countAllLuckyDraw").list();
		if (longs.size() > 0){
			if(longs.get(0)!=null){
				return longs.get(0).intValue();
			}
		}
		return 0;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<LuckyDrawG1> findByRef(String refNo, String gcif, String status) {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("LuckyDrawG1.findByRefModule").setString("refNo", refNo).setString("customerId", gcif).setString("status", status).list();
	}

	@Override
	public LuckyDrawG1 findById(long id) {
		// TODO Auto-generated method stub
		return (LuckyDrawG1) getSession().get(LuckyDrawG1.class, id);
	}
}
